//---------------------------------------
// Company List View
// --------------
// The DOM element for a list of company items...
//---------------------------------------
var CompanyListView = Backbone.View.extend({

	el:  $("#companies_holder"),
	
	initialize: function(options) {
		this.map = options.map;
		this.model.on('add', this.added_company, this);
		
		//initialize position
		this.$el.css({display: 'none', right:'20px', top: '120px'}, 2000);
		this.$el.fadeIn('500');
		
		this.list_container = $('#companies_list_holder ul', this.$el);
		
		this.render();
	},
	
	//----------------------------------
	// Events and event handlers
	//----------------------------------
	events: {
		
	},
	//----------------------------------
	// END Events and event handlers
	//----------------------------------
	
	//---------------------------------------
	// If a new company is added, create the proper views and render
	//---------------------------------------
	added_company : function (company){
		var marker_view = new CompanyMarkerView({ model: company, map: this.map });
		var item_view = new CompanyListItemView({ model: company, marker_view : marker_view });
		$(this.list_container).append(item_view.render().el);
	},
	
	//---------------------------------------
	// Render all
	//---------------------------------------
	render: function() {
		this.model.each (this.added_company, this);
	}
});